package cn.wenhe9.novel.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author DuJinliang
 * 2022/5/2
 */
@EnableSwagger2
@Configuration
@Profile("dev")
public class SwaggerConfig {
    @Bean
    public Docket adminDocket(){
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("novel-api")
                .apiInfo(novelApiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("cn.wenhe9.novel"))
                .paths(PathSelectors.any())
                .build();
    }

    public ApiInfo novelApiInfo(){
        return new ApiInfoBuilder()
                .title("小说精品屋")
                .description("小说精品屋-接口文档")
                .version("1.0")
                .contact(new Contact("djl", "http://wenhe9.cn", "dujinliang9@163.com"))
                .build();
    }
}
